const fileReader = new FileReader()
const transFormFileERROR = new Error('Blob to dataURL fail')
const BlobTypeERROR = new Error('File must be blob type')
export const getDataURL = function (blobFile) {
  return new Promise((resolve, reject) => {
    if (!(blobFile instanceof Blob)) {
      return reject(BlobTypeERROR)
    }
    fileReader.readAsDataURL(blobFile)
    fileReader.onload = () => {
      resolve(fileReader.result)
    }
    fileReader.onerror = () => {
      reject(transFormFileERROR)
    }
  })
}
